package com.jt.www.biz.order_pc.controller;

import com.jt.www.biz.order_pc.service.PolicyService;
import com.jt.www.model.param.policy.PolicyForAppCaseQo;
import com.jt.www.model.param.policy.RenewalQo;
import com.jt.www.model.remote.product.RiskInfoVo;
import com.jt.www.model.reps.GenericListResponse;
import com.jt.www.model.vo.policy.EduIndexMsgVO;
import com.jt.www.model.vo.policy.PolicyFormAppCaseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @ProjectName: edu-svc
 * @ClassName: PolicyController
 * @Author: lq
 * @Description: 保单相关信息查询接口
 * @Date: 2019-10-30 11:10
 * @Version: 1.0
 */
@Api(value = "查询保单列表", tags = {"POLICY-API"}, description = "查询保单列表接口")
@RestController
@RequestMapping(value = "/policy/v1")
public class PolicyController {

    public static final Logger log = LoggerFactory.getLogger(PolicyController.class);
    @Autowired
    private PolicyService policyService;

    /**
     * 我学保续保保单列表查询接口
     *
     * @param renewalQo
     * @return RenewalVO
     * @throws Exception
     */
    @ApiOperation(value = "我学保续保保单列表", httpMethod = "POST")
    @PostMapping(value = "/selectRenewalList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseEntity selectRenewalList(@RequestBody RenewalQo renewalQo) throws Exception {
        String findCode = "EDU_" + System.currentTimeMillis();
        return policyService.selectRenewalList(renewalQo, findCode);
    }

    /**
     * 索赔小程序保单列表查询接口(仅查询我学保保单)
     *
     * @param policyForAppCaseQo
     * @return PolicyFormAppCaseVO
     * @throws Exception
     */
    @ApiOperation(value = "索赔小程序保单列表(仅查询我学保保单)", httpMethod = "POST")
    @PostMapping(value = "/selectPolicyForAppCase", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public GenericListResponse<PolicyFormAppCaseVO> selectPolicyForAppCase(@RequestBody PolicyForAppCaseQo policyForAppCaseQo) throws Exception {
        String findCode = "EDU_" + System.currentTimeMillis();
        return policyService.selectPolicyForAppCase(policyForAppCaseQo, findCode);
    }

    /**
     * 附加险列表查询接口
     *
     * @param appCode
     * @param productCode
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "附加险列表查询接口", httpMethod = "GET")
    @GetMapping(value = "/selectRiskList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseEntity<GenericListResponse<RiskInfoVo>> selectRiskList(@RequestParam(value = "appCode", required = true) String appCode,
                                                                          @RequestParam(value = "productCode", required = true) String productCode) throws Exception {
        String findCode = "EDU_" + System.currentTimeMillis();
        return policyService.selectRiskList(appCode, productCode, findCode);
    }

    /**
     * 业务端首页实时保单信息查询
     *
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "业务端首页实时保单信息查询", httpMethod = "GET")
    @GetMapping(value = "/selectEduIndexMsg", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public GenericListResponse<EduIndexMsgVO> selectEduIndexMsg() throws Exception {
        return policyService.selectEduIndexMsg();
    }

}
